home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1996 January / macformat-033.iso / mac / Shareware City / Developers / ABox.v1.8 / CPlus Files / ABUEnvQuickTime.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-23  |  5.8 KB  |  259 lines  |  [TEXT/MMCC]

  1. /*    
  2.     Copyright © 1991-1995 by TopSoft Inc.  All rights reserved.
  3.  
  4.     You may distribute this file under the terms of the TopSoft
  5.     Artistic License, accompanying this package.
  6.     
  7.     This file was developed by George (ty) Tempel in connection with TopSoft, Inc..
  8.     See the Modification History for more details.
  9.  
  10. Product
  11.     About Box
  12.  
  13. FILE
  14.     ABUEnvQuickTime.c
  15.  
  16. NAME
  17.     ABUEnvQuickTime.c, part of the ABox project source code,
  18.     responsible for mix-in handling the AboutBox quicktime environment stuff.
  19.  
  20. DESCRIPTION
  21.     This file contains defines for the about box modules.
  22.     
  23. DEVELOPED BY
  24.     George (ty) Tempel                netromancr@aol.com
  25.     All code in this file, and its associated header file was
  26.     Created by George (ty) Tempel in connection with the TopSoft, Inc.
  27.     "FilterTop" application development, except where noted.
  28.  
  29. CARETAKER - George (ty) Tempel <netromancr@aol.com>
  30.      Please consult this person for any changes or suggestions to this file.
  31.  
  32. MODIFICATION HISTORY
  33.  
  34.     dd mmm yy    -    xxx    -    patchxx: description of patch
  35.     10 June 94    -    ty    -    Initial Version Created
  36.     20-july-94    -    ty    -    initial version released
  37.     23-may-95    -    ty    -    changes for compatibility with the CodeWarrior CW6
  38.                             release and the associated Universal Headers from Apple:
  39.                             most methods that returned references now have "Ref" at
  40.                             the end of their methods names to prevent possible collisions
  41.                             with datatypes and classes of the same name (older versions
  42.                             of the compiler didn't have a problem with this).
  43.  
  44. */
  45.  
  46. /*===========================================================================*/
  47.  
  48. /*======= Segmentation directives ========*/
  49.  
  50. #ifdef USE_MANUAL_SEGMENTATION
  51. #pragma segment ty
  52. #endif
  53.  
  54. /*============ Header files ==============*/
  55.     
  56. #include     "ABUEnvQuickTime.h"
  57.  
  58. /*=============== Globals ================*/
  59.  
  60. #define        kABstopMovieController            ((void *)0)
  61.  
  62. /*================ CODE ==================*/
  63.  
  64.  
  65. /*=============================== ABUEnvQuickTime::ABUEnvQuickTime ================================*/
  66. ABUEnvQuickTime::ABUEnvQuickTime(void)
  67. {
  68.     mController = NULL;
  69.     mMovie = NULL;
  70. }    // end ABUEnvQuickTime
  71.  
  72.  
  73. /*=============================== ABUEnvQuickTime::~ABUEnvQuickTime ================================*/
  74. ABUEnvQuickTime::~ABUEnvQuickTime(void)
  75. {
  76.     this->Close();
  77. }    // end ~ABUEnvQuickTime
  78.  
  79.  
  80.  
  81. /*=============================== ABUEnvQuickTime::IsPresent ================================*/
  82. Boolean    ABUEnvQuickTime::IsPresent(void)
  83. {
  84.     if (this->CheckGestalt(gestaltQuickTime) == noErr)
  85.     {
  86.         this->IndicatorRef() = true;
  87.     } else {
  88.         this->IndicatorRef() = false;
  89.         
  90.     } // end if block
  91.     return this->IndicatorRef();
  92. }    // end IsPresent
  93.  
  94.  
  95.  
  96. /*=============================== ABUEnvQuickTime::Feature ================================*/
  97. Boolean    ABUEnvQuickTime::Feature(long mask)
  98. {
  99.     return (this->ResultRef() & mask);
  100. }    // end Feature
  101.  
  102.  
  103. /*=============================== ABUEnvQuickTime::Initialize ================================*/
  104. OSErr    ABUEnvQuickTime::Initialize(void)
  105. {
  106.     if (!this->IsPresent())
  107.         return noErr;
  108.         
  109.     return ::EnterMovies();
  110. }    // end Initialize
  111.  
  112.  
  113.  
  114. /*=============================== ABUEnvQuickTime::Close ================================*/
  115. OSErr    ABUEnvQuickTime::Close(void)
  116. {
  117.     OSErr    error = noErr;
  118.     
  119.     if (!IsPresent())
  120.         return noErr;
  121.         
  122.     this->CleanUp();
  123.     
  124.     //ExitMovies();
  125.     
  126.     this->CheckedRef() = false;
  127.     this->IndicatorRef() = false;
  128.     this->ResultRef() = 0;
  129.     
  130.     return error;
  131. }    // end Close
  132.  
  133.  
  134.  
  135. /*=============================== ABUEnvQuickTime::CleanUp ================================*/
  136. void    ABUEnvQuickTime::CleanUp(void)
  137. {
  138.     OSErr    error = noErr;
  139.  
  140.     if (! this->IsPresent())
  141.         return;
  142.     
  143.     this->End();
  144.     if (this->HasController())
  145.     {
  146.         ::CloseComponent(this->MovieControllerRef());
  147.         this->MovieControllerRef() = NULL;
  148.     }
  149.     
  150.     if (this->HasMovie())
  151.     {
  152.         ::DisposeMovie(this->MovieRef());
  153.         this->MovieRef() = NULL;
  154.     }
  155.     
  156.     error = ::GetMoviesError();
  157.  
  158.     return;
  159. }    // end CleanUp
  160.  
  161.  
  162.  
  163.  
  164. /*=============================== ABUEnvQuickTime::Begin ================================*/
  165. OSErr    ABUEnvQuickTime::Begin(void)
  166. {
  167.     OSErr    error = noErr;
  168.     
  169.     if (!this->IsPresent())
  170.         return error;
  171.     else if (this->DoesntHaveMovie())
  172.         return error;
  173.         
  174.     ::ShowMoviePoster(this->MovieRef());            //    1.0a3 ty ...added to show the poster frame
  175.     error = ::GetMoviesError();
  176.  
  177.     if (this->DoesntHaveController())    
  178.     {            //    1.0a3 ty ... additions for movie controller support
  179.         //
  180.         //    we had problems creating the controller, so let's just
  181.         //    show the movie as it stands.
  182.         //
  183.         
  184.         //    now play
  185.         //
  186.         ::GoToBeginningOfMovie(this->MovieRef());
  187.         error = ::GetMoviesError();
  188.         if (error) 
  189.         {
  190.             this->CleanUp ();
  191.             return (error);
  192.         }    //    end if block
  193.     
  194.     
  195.         error = ::PrerollMovie (this->MovieRef(), 0, 0);
  196.         if (error) 
  197.         {
  198.             this->CleanUp ();
  199.             return (error);
  200.         }    //    end if block
  201.             
  202.         ::SetMovieActive (this->MovieRef(), true);
  203.         error = ::GetMoviesError();
  204.         if (error) 
  205.         {
  206.             this->CleanUp ();
  207.             return (error);
  208.         }    //    end if block
  209.         
  210.         ::StartMovie(this->MovieRef() = this->MovieRef());
  211.         error = ::GetMoviesError();
  212.         if (error) 
  213.         {
  214.             this->CleanUp ();
  215.             return (error);
  216.         }    //    end if block
  217.     
  218.         while (!::IsMovieDone(this->MovieRef()))
  219.             ::MoviesTask(this->MovieRef(), (long)0);
  220.     
  221.     }    //    end if block...
  222.     
  223.     return error;
  224. }    // end Begin
  225.  
  226.  
  227.  
  228.  
  229. /*=============================== ABUEnvQuickTime::End ================================*/
  230. OSErr    ABUEnvQuickTime::End(void)
  231. {
  232.     OSErr            error = noErr;
  233.     ComponentResult    componentResult;
  234.     
  235.     if (! this->IsPresent())
  236.         return error;
  237.         
  238.     if (this->HasController())
  239.     {
  240.         //    1.0a3 patch ty ... added MCDoAction(0) to stop the controller dead in its tracks
  241.         componentResult = ::MCDoAction(this->MovieControllerRef(), mcActionPlay, kABstopMovieController); //    rate=zero to stop
  242.     }    //    end if block
  243.  
  244.     if (this->HasMovie()) 
  245.     {
  246.         //    1.0a3 patch ty ... added StopMovie(gTheMovie) to stop the movie dead in its tracks
  247.         ::StopMovie(this->MovieRef());
  248.     }    //    end if block
  249.     
  250.     error = ::GetMoviesError();
  251.  
  252.     
  253.     return error;
  254. }    // end End
  255.  
  256.  
  257.  
  258.  
  259.